<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<div class="tophead">
  <div class="warp">
    <div class="flhead">
      <ul>
        <div class="dwei"></div>
        <li style="float:left">武汉</li>
      </ul>
    </div>
    <div class="otinfo">
      <li>
        <a href="/">首页</a>
      </li>
      <li><a href="${ctx}/guide.htm">选房</a></li>
      <li><a href="##">小区</a></li>
      <li><a href="##">小二</a></li>
      <li><a href="##">租售宝支付</a></li>
      <li><a href="##">金融贷款</a></li>
      <li><a href="##">服务</a></li>
      <li><a href="##">问答</a></li>
      <li><a href="##">理财</a></li>
    </div>

    <div class="cart" id="login_show">
      <div class="denglu">


        <c:if test="${ishop.state}">
          <a href="${ctx}/my.htm" id="login_box">${ishop.account}</a>
          <a href="${ctx}/logout.htm">退出</a>
        </c:if>
        <c:if test="${!ishop.state}">
          <a href="${ctx}/goLogin.htm" id="login_box">登录</a>
          <a href="${ctx}/goRegister.htm">注册</a>
        </c:if>

      </div>
      <%--<div class="helpce">
        <a href="##">帮助中心 | </a>
        <a href="##">网站导航</a>
      </div>--%>

      <div class="clear"></div>
    </div>


  </div>
</div>
<div class="header">
  <div class="warp">
    <div id="logo">
      <a href="##">
        <img src="${static_url}/ui/app/assets/images/logo.png" width="266" height="65" title="易房网">
      </a>
    </div>

    <dl class="topnav meun">
      <dd><a href="${ctx}/index.htm" <c:if test="${myNav=='index'}">class="active"</c:if> >首页</a></dd>
      <dd><a href="${ctx}/guide.htm" <c:if test="${myNav=='guide'}">class="active"</c:if> id="dstas">选房</a></dd>
      <dd><a href="##">小区</a></dd>
      <dd><a href="##">小二</a></dd>
      <dd><a href="##">问答</a></dd>
    </dl>

    <div class="header-toolbar">
      <div class="header-toolbar-item">
        <div class="minicart">
          <div class="h" id="header-toolbar-minicart-h">
            <a href="#" rel="nofollow" timetype="timestamp" onmouseover="ajaxShowCart(true)" onmouseover="hideCart()">
              我的购物车
              <span><em id="header-cart-total">0</em><b></b></span>
            </a>
            <i></i>
            <s></s>
            <u></u>
          </div>
          <div class="b" id="header-toolbar-minicart-content" style="display: none;">
            <div class="minicart-pro-empty" id="minicart-pro-empty" style="">
              <span class="icon-minicart">您的购物车是空的，赶紧选购吧！</span>
            </div>
            <div id="minicart-pro-list-block" style="display: none;">
              <ul class="minicart-pro-list" id="minicart-pro-list"></ul>
            </div>
            <div class="minicart-pro-settleup" id="minicart-pro-settleup" style="display: none;">
              <p>共<em id="micro-cart-total">0</em>件商品，金额合计<b id="micro-cart-totalPrice"></b></p>
              <a class="button-minicart-settleup" href="${ctx}/order/goOrder.htm">去结算</a>
            </div>

          </div>
        </div>
      </div>
    </div>
  </div>
</div>
<script>

  function li(item){
    //console.log(item);
    $("#minicart-pro-list").empty();
    var tpl = "";
    for(var i=0;i<item.length;i++){
       tpl =
              '<li class="minicart-pro-item" id="minicart-pro-item-'+item[i].id+'">'+
              '<div class="pro-info">'+
              '<div class="p-img">'+
              '<a href="${ctx}/detail.htm?id='+item[i].id+'" title="" target="_blank">'+
              '<img src="${fileServerUrl}/'+item[i].photo+'" width="78px" height="78px">'+
              '</a>'+
              '</div>'+
              '<div class="p-name">'+
              '<a href="${ctx}/detail.htm?id='+item[i].id+'" title="" target="_blank">'+
              item[i].name+
              '</a>'+
              '</div>'+
              '<div class="p-status">'+
              '<div class="p-price">'+
              '<b>¥&nbsp;'+item[i].price+'万</b>'+
              '</div>'+
              '</div>'+
              '<a href="javascript:;" class="icon-minicart-del" title="删除" onclick="deleteCart('+item[i].id+')">删除</a>'+
              '</div>'+
              '</li>';
      $("#minicart-pro-list").append(tpl);
    }
  }

  function hideCart(){
    $("#header-toolbar-minicart-content").hide();
  }

  function ajaxShowCart(isShow){
    $.post("${ctx}/showCartAjax.htm",function(data){
      if(data.success){
        $("#header-cart-total").text(data.total);
        if(isShow){
          $("#minicart-pro-empty").hide();
          li(data.records);
          $("#minicart-pro-list-block").show();
          $("#minicart-pro-settleup").show();
          $("#micro-cart-total").text(data.total);
          $("#micro-cart-totalPrice").html("¥&nbsp;"+data.totalPrice+"万");
        }
      }else{
        $("#minicart-pro-empty").show();
        $("#minicart-pro-list-block").hide();
        $("#minicart-pro-settleup").hide();
      }
      if(isShow) {
        $("#header-toolbar-minicart-content").show();
      }
    },"json");
  }

  function deleteCart(goodsId){
    $.post("${ctx}/deleteCartAjax.htm",{goodsId:goodsId},function(data){
      if(data.success) {
          $("#minicart-pro-item-"+goodsId).remove();
      }
    },"json");
  }
  $(function(){
    ajaxShowCart(false);
  })
</script>
